# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Kerrick Staley <mail@kerrickstaley.com>

pkgname=pyzy
pkgver=1.1
pkgrel=2
pkgdesc='The Chinese PinYin and Bopomofo conversion library'
arch=('loong64' 'x86_64')
url='https://github.com/openSUSE/pyzy'
license=('LGPL')
depends=('glib2' 'sqlite' 'util-linux')
makedepends=('doxygen' 'gnome-common' 'python')
source=("https://github.com/openSUSE/pyzy/archive/$pkgver/$pkgname-$pkgver.tar.gz"
        $pkgname-fail-on-error.patch::https://github.com/openSUSE/pyzy/pull/1.patch
        $pkgname-py3-fix.patch::https://github.com/openSUSE/pyzy/pull/2.patch)
sha512sums=('c69ebfa93b8cc71df58a4966648523d6ed36698ef08a48137168edfc5ed590b73141b82193f474d0bf206acf59d0676f08b0778d75a39ffe32cbba1bfafe7f12'
            'fc37482b9ab6248bd8e6780c57ec1b240d53d16badd9502f73a2a2204618a7bef1ac73f18326108cc7ddbd86632bd5f76cf9ea360e0d119c511de22ae10f40a6'
            '37ffa5351b3f515f6855536d77ca3cd5ca2ccd0f36f0f306ff35757bdd9c5581bf95ccfced9bdeb29c939fe2837684d3a41a22b4e5f4926579e6e7694f935f9a')

prepare() {
  cd pyzy-$pkgver
  patch -p1 -i ../$pkgname-fail-on-error.patch
  patch -p1 -i ../$pkgname-py3-fix.patch
}

build() {
  cd pyzy-$pkgver
  ./autogen.sh --prefix=/usr
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd pyzy-$pkgver
  make DESTDIR="$pkgdir" install
}
